package test.core;

import static org.junit.Assert.*;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.junit.Test;

import hyl.core.MyDate;
import hyl.core.MyFun;
import hyl.core.run.MyRun;
import hyl.core.run.MyTimer;

public class testrun {

//	@Test
	public void test1() {
		MyRun mr =  MyRun.getInstance("测试");
		mr.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(1000);
				System.out.println("11");
			}

		});
		mr.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(4000);
				System.out.println("44");
			}
		});
		mr.waitAndClose();
	}
	public void test2() {
		MyRun es = MyRun.getInstance("测试");
		es.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(1000);
				System.out.println("22");
			}

		});
		es.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(4000);
				System.out.println("33");
			}
		});
	//	es.shutdown();
	}

	public void test3() {
	Thread td=new Thread(new Runnable() {
		@Override
		public void run() {
			MyDate.sleep(4000);
			System.out.println("55");
		}
	});

	td.start();
	//td.stop();
	//	es.shutdown();
	}
	
	public void testRun() {
		MyRun es = MyRun.getInstance("测试");
		es.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(1000);
				System.out.println("22");
			}

		});
		es.call(new Runnable() {
			@Override
			public void run() {
				MyDate.sleep(4000);
				System.out.println("33");
			}
		});
		//es.close();
		MyRun.closeAll();
	//	es.shutdown();
	}
	
	public void testTimer() {
		MyTimer es = MyTimer.getInstance();
		es.start(new Runnable() {
			@Override
			public void run() {	
				System.out.println("11");
			}

		},1000);
		es.start(new Runnable() {
			@Override
			public void run() {
		
				System.out.println("44");
			}
		},3000);
		MyDate.sleep(6000);
	//	es.close();
		MyTimer.closeAll();
	//	es.shutdown();
	}
	public void fun放大缩小() {
		long l=398453333321L;
		String s=MyFun.long缩小(l,9);

		System.out.println(MyFun.long缩小(l, 9)); 
		System.out.println(MyFun.long放大(s, 7)); 
	}
	public static void main(String[] args) {
		testrun t=new testrun();
		// t.	test1() ;
		// t.	testRun() ;
		// t.	testTimer() ;
		 t. fun放大缩小();
		// t.	test3() ;
	}
}
